import 'package:aio/aio.dart';
import 'package:app/src/http/bean/clockin/attendances.dart';
import 'package:app/src/http/bean/http_data.dart';

///加班审核：加班审批
class WorkOvertimeApproval extends BaseBean {
  String? Id = ""; //主键ID
  String? CurWfId = ""; //当前流程
  String? PersonId = ""; //
  String? AttendanceId = ""; //班组Id
  String? WorkStartTime = ""; //
  String? WorkEndTime = ""; //
  String? GroupId = ""; //
  String? GroupCheckTimeId = ""; //
  String? CheckOutTime = ""; //
  String? FactoryId = ""; //

  String? TheName = ""; //姓名
  String? FactoryName = ""; //工厂 FactoryName3
  String? ClassName = ""; //班组
  String? OvertimeHours = ""; //当前加班时长（分钟） OvertimeHours3
  String? Overtime = ""; //当前加班时间
  String? Attendancetime = ""; //考勤时间
  String? Flightdate = ""; //班次日期
  String? ShiftName = ""; //班次名称
  String? Flighttime = ""; //班次时间
  bool isInClass = false; //调班
  bool isInClassEnable = true; //调班,是否开启点击能力
  bool isOvertime = false; //是否加班

  @override
  fromJson(Map<String, dynamic> json) {
    // TODO: implement fromJson
    Id = json["Id"]?.toString() ?? "";
    CurWfId = json["CurWfId"]?.toString() ?? "";
    PersonId = json["PersonId"]?.toString() ?? "";
    AttendanceId = json["AttendanceId"]?.toString() ?? "";
    WorkStartTime = json["WorkStartTime"]?.toString() ?? "";
    WorkEndTime = json["WorkEndTime"]?.toString() ?? "";
    GroupId = json["GroupId"]?.toString() ?? "";
    GroupCheckTimeId = json["GroupCheckTimeId"]?.toString() ?? "";
    CheckOutTime = json["CheckOutTime"]?.toString() ?? "";
    FactoryId = json["FactoryId"]?.toString() ?? "";

    TheName = json["TheName"]?.toString() ?? "";
    FactoryName = json["FactoryName"]?.toString() ?? "";
    ClassName = json["ClassName"]?.toString() ?? "";
    OvertimeHours = json["OvertimeHours"]?.toString() ?? "";
    Overtime = json["Overtime"]?.toString() ?? "";
    Attendancetime = json["Attendancetime"]?.toString() ?? "";
    Flightdate = json["Flightdate"]?.toString() ?? "";
    ShiftName = json["ShiftName"]?.toString() ?? "";
    Flighttime = json["Flighttime"]?.toString() ?? "";
    if (json["isInClass"]?.toString()?.trim()?.toLowerCase() == "true") {
      isInClass = true;
    } else {
      isInClass = false;
    }
    if (json["isInClassEnable"]?.toString()?.trim()?.toLowerCase() == "true") {
      isInClassEnable = true;
    } else {
      isInClassEnable = false;
    }
    if (json["isOvertime"]?.toString()?.trim()?.toLowerCase() == "true") {
      isOvertime = true;
    } else {
      isOvertime = false;
    }
  }

  @override
  instance() {
    // TODO: implement instance
    return WorkOvertimeApproval();
  }

  @override
  Map<String, dynamic> toJson() {
    // TODO: implement toJson
    var map = <String, dynamic>{};
    map["Id"] = Id;
    map["CurWfId"] = CurWfId;
    map["PersonId"] = PersonId;
    map["AttendanceId"] = AttendanceId;
    map["WorkStartTime"] = WorkStartTime;
    map["WorkEndTime"] = WorkEndTime;
    map["GroupId"] = GroupId;
    map["GroupCheckTimeId"] = GroupCheckTimeId;
    map["CheckOutTime"] = CheckOutTime;
    map["FactoryId"] = FactoryId;

    map["TheName"] = TheName;
    map["FactoryName"] = FactoryName;
    map["ClassName"] = ClassName;
    map["OvertimeHours"] = OvertimeHours;
    map["Overtime"] = Overtime;
    map["Attendancetime"] = Attendancetime;
    map["Flightdate"] = Flightdate;
    map["ShiftName"] = ShiftName;
    map["Flighttime"] = Flighttime;
    map["isInClass"] = isInClass;
    map["isOvertime"] = isOvertime;
    return map;
  }
}

///加班审核：排班
class Scheduling extends BaseBean {
  DateTime dateTime =
      DateTime.now().add(Duration(days: 1)); //日期加一;(获取当前日期的下一天日期)
  String? Date = ""; //日期
  Factory? factory = null; //工厂 FactoryName3
  MyGroupBcInfo? GroupBcInfo = null; //班组 ClassName
  MyAttendances? Attendance = null; //班次 shift

  ///Operation 操作；Synchronousdown 向下同步

  ///添加一个排班
  Scheduling add() {
    Scheduling scheduling = Scheduling();
    scheduling.dateTime = dateTime.add(Duration(days: 1)); //日期加一
    return copy(scheduling);
  }

  ///复制
  Scheduling copy(Scheduling scheduling) {
    if (factory != null) {
      Factory? factory2 = Factory();
      factory2.FactoryId = factory?.FactoryId ?? "";
      factory2.FactoryName = factory?.FactoryName ?? "";
      factory2.FactoryURL = factory?.FactoryURL ?? "";
      factory2.key = factory?.key;
      factory2.value = factory?.value;
      scheduling.factory = factory2; //工厂
    }
    if (GroupBcInfo != null) {
      MyGroupBcInfo? groupBcInfo2 = MyGroupBcInfo();
      groupBcInfo2.GroupId = GroupBcInfo?.GroupId ?? "";
      groupBcInfo2.GroupName = GroupBcInfo?.GroupName ?? "";
      groupBcInfo2.Attendances = GroupBcInfo?.Attendances;
      groupBcInfo2.key=GroupBcInfo?.key;
      groupBcInfo2.value=GroupBcInfo?.value;
      scheduling.GroupBcInfo = groupBcInfo2; //班组
    }
    if (Attendance != null) {
      MyAttendances? attendance2 = MyAttendances();
      attendance2.AttendanceId = Attendance?.AttendanceId ?? "";
      attendance2.WorkTypeName = Attendance?.WorkTypeName ?? "";
      attendance2.OffWorkTime = Attendance?.OffWorkTime ?? "";
      attendance2.OnWorkTime = Attendance?.OnWorkTime ?? "";
      scheduling.Attendance = attendance2;
    }
    return scheduling;
  }

  @override
  fromJson(Map<String, dynamic> json) {
    // TODO: implement fromJson
    Date = json["Date"]?.toString() ?? "";
    factory = setGenericFromJson(json, 'factory', Factory(), "");
    GroupBcInfo = setGenericFromJson(json, 'GroupBcInfo', MyGroupBcInfo(), "");
    Attendance = setGenericFromJson(json, 'Attendanceo', MyAttendances(), "");
  }

  @override
  instance() {
    // TODO: implement instance
    return Scheduling();
  }

  @override
  Map<String, dynamic> toJson() {
    // TODO: implement toJson
    var map = <String, dynamic>{};
    Date = dateTime.toString(); //fixme 日期
    map["Date"] = Date;
    map["factory"] = factory;
    map["GroupBcInfo"] = GroupBcInfo;
    map["Attendance"] = Attendance;
    return map;
  }
}
